{include file="public/head"}
<style>
    .x-body {
        min-width: 1000px;
    }

    body {
        overflow-x: scroll;
    }

    a {
        color: #01AAED;
    }
</style>
<body>
<div class="x-body">
    <div class="lotus-nav" style="height: 30px">
        <span class="x-right">共有数据:<i class="i_count">{$data->total()}</i>条
        <button onclick="javascript:location.reload()" class="layui-btn-default ">
            <i class="layui-icon layui-icon-refresh"></i>
        </button>
        </span>
    </div>


    <table class="layui-table">
        <thead>
        <tr>
            <th>名称</th>
            <th style="width: 120px;text-align:center">修改时间</th>
            <th style="width: 80px;text-align:center">类型</th>
            <th style="width: 80px;text-align:center">大小</th>
            <th style="width: 90px;text-align:center">操作</th>
        </thead>
        <tbody>

        {volist name="list" id="vo"}
        <tr>
            <td>
                <img src="{$vo.path}" onclick="previewImg(this)">
                <a href="javascript:void(0);" onclick="previewImgUrl('{$vo.path}')">{$vo.name}</a>
            </td>
            <td style="text-align:center">{$vo['timestamp']|date="Y-m-d H:i",###}</td>
            <td style="text-align:center">{$vo.postfix}</td>
            <td style="text-align:center">{$vo.size}</td>
            <td style="text-align:center">
                <a class="layui-btn layui-btn-normal layui-btn-xs"
                   href="{:url('admin/product/uploadImg')}?filename={$vo.path}">下载</a>
                <button onclick="del(this,'{$vo.path}','{$vo.id}','file')"
                        class="layui-btn layui-btn-xs layui-btn-danger">
                    删除
                </button>
            </td>
        </tr>
        {/volist}

        </tbody>
    </table>
    <div class="page">
        <div>
            {$data->render()}
        </div>
    </div>
</div>
</body>
{include file="public/foot"}
<script>
    function del(obj, path, id, type) {
        layer.confirm("确认要删除吗？", function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/resource/resourceDel')}", {path: path, id: id, type: type}, function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        $(obj).parents('tr').remove();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }

            });
        });
    }
</script>
